home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / blankery / blanker / source / blankers / life / prefs.c < prev    next >
C/C++ Source or Header  |  1993-07-31  |  3KB  |  144 lines

  1. /*
  2.  *    Copyright (c) 1993 Michael D. Bayne.
  3.  *    All rights reserved.
  4.  *
  5.  *    Please see the documentation accompanying the distribution for distribution and disclaimer information.
  6.  */
  7.  
  8. #include <exec/types.h>
  9. #include <exec/memory.h>
  10.  
  11. #include <intuition/intuition.h>
  12. #include <intuition/screens.h>
  13.  
  14. #include <libraries/gadtools.h>
  15.  
  16. #include <clib/exec_protos.h>
  17. #include <clib/dos_protos.h>
  18. #include <clib/intuition_protos.h>
  19. #include <clib/graphics_protos.h>
  20. #include <clib/alib_protos.h>
  21. #include <clib/gadtools_protos.h>
  22. #include <clib/utility_protos.h>
  23.  
  24. #include "Life.h"
  25. #include "Life_rev.h"
  26. #include "/defs.h"
  27.  
  28. struct lPrefObject {
  29.     LONG Size;
  30.     LONG Generations;
  31.     LONG Density;
  32. };
  33.  
  34. VOID blank( VOID );
  35.  
  36.     struct    lPrefObject    nP;
  37. STATIC    const    UBYTE        VersTag[] = VERSTAG;
  38. extern    struct    Task        **Task;
  39. extern        UBYTE        *prefData;
  40.  
  41. VOID setLifePrefs( VOID )
  42. {
  43.     GT_SetGadgetAttrs( LifeGadgets[GD_BSIZE], LifeWnd, 0L, GTSL_Level, nP.Size, 0L );
  44.     GT_SetGadgetAttrs( LifeGadgets[GD_GENS], LifeWnd, 0L, GTSL_Level, nP.Generations, 0L );
  45.     GT_SetGadgetAttrs( LifeGadgets[GD_DENSE], LifeWnd, 0L, GTSL_Level, nP.Density, 0L );
  46. }
  47.  
  48. int OKClicked( VOID )
  49. {
  50.     CopyMem( &nP, prefData, sizeof( struct lPrefObject ));
  51.     return( QUIT );
  52. }
  53.  
  54. int TESTClicked( VOID )
  55. {
  56.     *Task = FindTask( 0L );
  57.     blank();
  58.     return( CONTINUE );
  59. }
  60.  
  61. int CANCELClicked( VOID )
  62. {
  63.     return( QUIT );
  64. }
  65.  
  66. int BSIZEClicked( VOID )
  67. {
  68.     nP.Size = LifeMsg.Code;
  69.     return( CONTINUE );
  70. }
  71.  
  72. int GENSClicked( VOID )
  73. {
  74.     nP.Generations = LifeMsg.Code;
  75.     return( CONTINUE );
  76. }
  77.  
  78. int DENSEClicked( VOID )
  79. {
  80.     nP.Density = LifeMsg.Code;
  81.     return( CONTINUE );
  82. }
  83.  
  84. int LifeVanillaKey( VOID )
  85. {
  86.     switch( LifeMsg.Code ) {
  87.     case 'o':
  88.         return( OKClicked() );
  89.     case 'c':
  90.         return( CANCELClicked() );
  91.     case 's':
  92.         GT_SetGadgetAttrs( LifeGadgets[GD_BSIZE], LifeWnd, 0L, GTSL_Level, ++(nP.Size) > 40 ? nP.Size = 40 :
  93.             nP.Size, 0L );
  94.         return( CONTINUE );
  95.     case 'S':
  96.         GT_SetGadgetAttrs( LifeGadgets[GD_BSIZE], LifeWnd, 0L, GTSL_Level, --(nP.Size) < 5 ? nP.Size = 5 :
  97.             nP.Size , 0L );
  98.         return( CONTINUE );
  99.     case 'g':
  100.         GT_SetGadgetAttrs( LifeGadgets[GD_GENS], LifeWnd, 0L, GTSL_Level, ++(nP.Generations) > 999 ?
  101.             nP.Generations = 999 : nP.Generations, 0L );
  102.         return( CONTINUE );
  103.     case 'G':
  104.         GT_SetGadgetAttrs( LifeGadgets[GD_GENS], LifeWnd, 0L, GTSL_Level, --(nP.Generations) < 5 ?
  105.             nP.Generations = 5 : nP.Generations , 0L );
  106.         return( CONTINUE );
  107.     case 'd':
  108.         GT_SetGadgetAttrs( LifeGadgets[GD_DENSE], LifeWnd, 0L, GTSL_Level, ++(nP.Density) > 99 ?
  109.             nP.Density = 99 : nP.Density, 0L );
  110.         return( CONTINUE );
  111.     case 'D':
  112.         GT_SetGadgetAttrs( LifeGadgets[GD_DENSE], LifeWnd, 0L, GTSL_Level, --(nP.Density) < 1
  113.             ? nP.Density = 1 : nP.Density , 0L );
  114.         return( CONTINUE );
  115.     case 't':
  116.         return( TESTClicked() );
  117.     default:
  118.         return( CONTINUE );
  119.     }
  120. }
  121.  
  122. VOID prefs( LONG command )
  123. {
  124.     switch( command ) {
  125.     case STARTUP:
  126.         CopyMem( prefData, &nP, sizeof( struct lPrefObject ));
  127.         if( !SetupScreen() ) {
  128.             if( !OpenLifeWindow()) setLifePrefs();
  129.             CloseDownScreen();
  130.         }
  131.         break;
  132.     case IDCMP:
  133.         if( HandleLifeIDCMP() != QUIT ) break;
  134.     case KILL:
  135.         CloseLifeWindow();
  136.         break;
  137.     }        
  138. }
  139.  
  140. LONG winSig( VOID )
  141. {
  142.     return( LifeWnd ? ( 1l << LifeWnd->UserPort->mp_SigBit ) : 0l );
  143. }
  144.